home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / gempp19.zoo / gem++19 / src / gempg.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-28  |  1.6 KB  |  93 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is Copyright 1992,1993 by Warwick W. Allison.
  4. //  This file is part of the gem++ library.
  5. //  You are free to copy and modify these sources, provided you acknowledge
  6. //  the origin by retaining this notice, and adhere to the conditions
  7. //  described in the file COPYING.LIB.
  8. //
  9. /////////////////////////////////////////////////////////////////////////////
  10.  
  11. // This code is not used at present.
  12.  
  13.  
  14. class GEMpolygon : public GEMvdiobject {
  15. public:
  16.     GEMpolygon(int RSCindex, GEMform& f, VDI& v, int maxpoints);
  17.     virtual ~GEMpolygon();
  18.  
  19.     void Set(int i, int x, int y);
  20.     void Get(int i, int& x, int& y);
  21.     void MaxNumberOfPoints(int n);
  22.     void NumberOfPoints(int n);
  23.  
  24. private:
  25.     int *pxy;
  26.     int mxy,nxy;
  27.     int ox,oy;
  28.  
  29. protected:
  30.     virtual void Draw(int x, int y);
  31. };
  32.  
  33. GEMpolygon::GEMpolygon(int RSCindex, GEMform& f, VDI& v, int n) :
  34.     GEMvdiobject(RSCindex,f,v),
  35.     mxy(n+1),
  36.     nxy(mxy),
  37.     pxy(new int[mxy*2]),
  38.     ox(0),oy(0)
  39. {
  40. }
  41.  
  42. GEMpolygon::~GEMpolygon()
  43. {
  44.     delete pxy;
  45. }
  46.  
  47. void GEMpolygon::Set(int i, int x, int y)
  48. {
  49.     i*=2;
  50.     pxy[i++]=x+ox;
  51.     pxy[i]=y+oy;
  52. }
  53.  
  54. void GEMpolygon::Get(int i, int& x, int& y)
  55. {
  56.     i*=2;
  57.     x=pxy[i++]-ox;
  58.     y=pxy[i]-oy;
  59. }
  60.  
  61. void GEMpolygon::NumberOfPoints(int n)
  62. {
  63.     nxy=n;
  64. }
  65.  
  66. void GEMpolygon::MaxNumberOfPoints(int n)
  67. {
  68.     delete pxy;
  69.     nxy=mxy=n;
  70.     pxy=new int[mxy*2];
  71. }
  72.  
  73. void GEMpolygon::MakeConvex()
  74. {
  75.     nxy=BoundingPolygon(nxy,pxy);
  76. }
  77.  
  78. void GEMpolygon::Draw(int x, int y)
  79. {
  80.     if (ox!=x) {
  81.         for (int i=0; i<nxy*2; i+=2) pxy[i]+=x-ox;
  82.         ox=x;
  83.     }
  84.  
  85.     if (oy!=y) {
  86.         for (int i=1; i<nxy*2; i+=2) pxy[i]+=y-oy;
  87.         oy=y;
  88.     }
  89.  
  90.     vdi.fillarea(nxy,pxy);
  91. }
  92.  
  93.